package com.example.Controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.Service.impl.DigangServiceImpl;
import com.example.pojo.Digang;
import com.example.util.Result;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@Api(tags = "调岗管理")
public class DigangController {

    @Autowired
    private DigangServiceImpl digangService;

    @RequestMapping("/DiGang")  //添加
    public Result updateUserDepart(@RequestBody Digang digang){
        int insert = digangService.insert(digang);
        if (insert>0){
            return new Result("200","添加成功",insert);
        }
        return new Result("400","添加失败",insert);
    }

    @RequestMapping("/selectAllInD")
    public Result selectAllInD(){   //查询全部
        List<Digang> digangs = digangService.selectAllInD();
        return new Result("400","添加失败",digangs);
    }

    @RequestMapping("/updateSelfAll") //修改状态
    public Result updateSelfAll(Integer id, Integer status){
         int row = digangService.updateSelfAll(id, status);
         if (row>0){
             return new Result("200","修改成功",row);
         }
        return new Result("200","修改失败",row);
    }

    @RequestMapping("/selectSelfAllInfo") //查询自己的列表
    public Result selectSelfAllInfo(String name){
        List<Digang> digangs = digangService.selectSelfAllInfo(name);
        return new Result("200","查询成功",digangs);
    }

}
